package com.tinyseed.emcp.api.basicdata.model;

import com.tinyseed.emcp.api.basicdata.domain.Organize;
import com.tinyseed.emcp.api.basicdata.domain.convert.DTOConvert;
import com.tinyseed.hmxx.admin.system.domain.Dept;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import java.util.Set;

/**
 * Organize
 *
 * @author tinyCode
 * @date 2019-11-22 21:42:02
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrganizeOutputDTO implements Serializable {

    /**
     * 主键
     */
    private Long id;

    /**
     * 组织机构
     */
    private String organizeName;

    /**
     * 父级id
     */
    private Long parentId;

    /**
     * 创建时间
     */
    private Timestamp createTime;

    /**
     * 最后修改时间
     */
    private Timestamp modifyTime;

    private List<Dept> deptList;

    /**
     * 创建人
     */
    private String creator;

    /**
     * 最后操作人
     */
    private String modifier;

    private List<OrganizeOutputDTO> children;

    private Set<Dept> dept;

    public Organize convertToOrganize() {
        OrganizeOutputDTOConvert convert = new OrganizeOutputDTOConvert();
        Organize result = convert.convert(this);
        return result;
    }

    private static class OrganizeOutputDTOConvert implements DTOConvert<OrganizeOutputDTO, Organize> {

        @Override
        public Organize convert(OrganizeOutputDTO organizeOutputDTO) {
            Organize organize = new Organize();
            BeanUtils.copyProperties(organizeOutputDTO, organize);
            return organize;
        }
    }

}
